﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Reservas.aspx.vb" Inherits="Hosteria_VS_Reservas" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    Mantenimiento de Reservas<br />
    <asp:FormView ID="fvReservas" runat="server" DataKeyNames="Id" 
        DataSourceID="SqlDataSource1">
        <EditItemTemplate>
            Nro:
            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
            <br />
            Habitación:
            <asp:TextBox ID="IdHabitacionTextBox" runat="server" 
                Text='<%# Bind("IdHabitacion") %>' />
            <br />
            Nombre:&nbsp;
            <asp:TextBox ID="ANombreDeTextBox" runat="server" 
                Text='<%# Bind("ANombreDe") %>' Width="294px" />
            <br />
            Desde:
            <asp:TextBox ID="DesdeTextBox" runat="server" Text='<%# Bind("Desde") %>' />
            <br />
            Hasta:
            <asp:TextBox ID="HastaTextBox" runat="server" Text='<%# Bind("Hasta") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Actualizar" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
        </EditItemTemplate>
        <InsertItemTemplate>
            Habitación:
            <asp:TextBox ID="IdHabitacionTextBox" runat="server" 
                Text='<%# Bind("IdHabitacion") %>' />
            <br />

            Nombre:
            <asp:TextBox ID="ANombreDeTextBox" runat="server" 
                Text='<%# Bind("ANombreDe") %>' Width="299px" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="ANombreDeTextBox" ErrorMessage="Debe ingresar un nombre" 
                ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>
            <br />
            Desde:
            <asp:TextBox ID="DesdeTextBox" runat="server" Text='<%# Bind("Desde") %>' />
            <br />
            Hasta:
            <asp:TextBox ID="HastaTextBox" runat="server" Text='<%# Bind("Hasta") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" 
                CommandName="Insert" Text="Confirmar Reserva" 
                onclick="InsertButton_Click" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancelar" 
                onclick="InsertCancelButton_Click" />
        </InsertItemTemplate>
        <ItemTemplate>
            Nro:
            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
            <br />
            Habitacion:
            <asp:Label ID="IdHabitacionLabel" runat="server" 
                Text='<%# Bind("IdHabitacion") %>' />
            <br />
            Cliente:
            <asp:Label ID="ANombreDeLabel" runat="server" Text='<%# Bind("ANombreDe") %>' />
            <br />
            Desde:
            <asp:Label ID="DesdeLabel" runat="server" Text='<%# Bind("Desde") %>' />
            <br />
            Hasta:
            <asp:Label ID="HastaLabel" runat="server" Text='<%# Bind("Hasta") %>' />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Editar" Visible="False" />
&nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Eliminar" Visible="False" />
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Nuevo" Visible="False" />
        </ItemTemplate>
    </asp:FormView>
    <asp:Label ID="lblReservaConfirmada" runat="server" style="font-weight: 700" 
        Text="Reserva Confirmada" Visible="False"></asp:Label>
    <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" 
        DeleteCommand="DELETE FROM [Reservas] WHERE [Id] = @Id" 
        InsertCommand="INSERT INTO [Reservas] ([IdHabitacion], [ANombreDe], [Desde], [Hasta]) VALUES (@IdHabitacion, @ANombreDe, @Desde, @Hasta)" 
        SelectCommand="SELECT [IdHabitacion], [Id], [ANombreDe], [Desde], [Hasta] FROM [Reservas]
WHERE [IdHabitacion] = @IdHabitacion" 
        
        UpdateCommand="UPDATE [Reservas] SET [IdHabitacion] = @IdHabitacion, [ANombreDe] = @ANombreDe, [Desde] = @Desde, [Hasta] = @Hasta WHERE [Id] = @Id">
        <DeleteParameters>
            <asp:Parameter Name="Id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="IdHabitacion" Type="String" />
            <asp:Parameter Name="ANombreDe" Type="String" />
            <asp:Parameter DbType="Date" Name="Desde" />
            <asp:Parameter DbType="Date" Name="Hasta" />
        </InsertParameters>
        <SelectParameters>
            <asp:Parameter Name="IdHabitacion" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="IdHabitacion" Type="String" />
            <asp:Parameter Name="ANombreDe" Type="String" />
            <asp:Parameter DbType="Date" Name="Desde" />
            <asp:Parameter DbType="Date" Name="Hasta" />
            <asp:Parameter Name="Id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
&nbsp;
</asp:Content>

